import { Controller, Get, Body, Put, Query, Param } from '@nestjs/common';
import { UserClient_Service } from './userClient.service';
import { ApiExtraModels, ApiTags } from '@nestjs/swagger';
import { util_ApiResponse_Base } from '@/common/util/apiResponse';
import {
  UserClient_Disabled_Dto,
  UserClient_DistrubuteFind_Dto,
  UserClient_Find_Dto,
} from './assets/userClient.dto';
import { util_Index_ReturnContent } from '@/common/util/index';
import { UserClient_AdmReturnUser_ReClass } from './assets/userClient.class';

@Controller('/adm/userClient')
@ApiTags('userClient 前台用户')
export class UserClient_Controller {
  constructor(private readonly userClient_Service: UserClient_Service) {}

  @Get('/list')
  @ApiExtraModels(UserClient_AdmReturnUser_ReClass)
  @util_ApiResponse_Base({
    dataType: 'dataType_list',
    type: UserClient_AdmReturnUser_ReClass,
  })
  async userClient_Adm_FindByPage(@Query() query: UserClient_Find_Dto): Promise<{
    data: {
      list: UserClient_AdmReturnUser_ReClass[];
      totalElements: number;
    };
  }> {
    return util_Index_ReturnContent(await this.userClient_Service.userClient_Adm_FindByPage(query));
  }

  @Put('/disabled')
  @util_ApiResponse_Base({
    dataType: 'dataType_string',
    description: '拉黑成功/取消拉黑成功',
    summary: '拉黑用户和取消拉黑',
  })
  async userClient_Adm_Disabled(@Body() body: UserClient_Disabled_Dto): Promise<{
    data: string;
  }> {
    return util_Index_ReturnContent(await this.userClient_Service.userClient_Adm_Disabled(body));
  }

  @Get('/distributeList')
  @util_ApiResponse_Base({
    dataType: 'dataType_list',
    summary: '推广者列表',
  })
  async userClient_DistributeFindByPage(@Query() query: UserClient_DistrubuteFind_Dto) {
    return util_Index_ReturnContent(
      await this.userClient_Service.userClient_DistributeFindByPage(query),
    );
  }
  @Put('/changeType/:id')
  @util_ApiResponse_Base({
    dataType: 'dataType_string',
    status: 201,
    description: '添加为固定推广者和降为普通推广者',
    type: '修改成功',
    summary: '添加为固定推广者和降为普通推广者',
  })
  async userClient_ChangeType(@Param('id') id: string) {
    return util_Index_ReturnContent(await this.userClient_Service.userClient_ChangeType(id));
  }
}
